<!DOCTYPE html>
<html>
<head>
    <meta name="layout" content="main"/>
    <g:set var="entityName" value="${message(code: 'estate.label', default: 'estate')}"/>
    <asset:stylesheet src="styles/css/menu.css"/>
    <title>导入搜索</title>
    <style>
    .table > tbody > tr > td {
        vertical-align: middle;
    }
    .buttonbar{
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    .file_show{
        height: 20px;
        font: normal normal normal 14px/30px 'Microsoft YaHei';
    }
    @media screen and (min-width:1900px) and (max-width:1920px) {
        .flex{
            display: flex;justify-content: center;align-items: center;
        }
    }
    .select2-container .select2-choices .select2-search-field input, .select2-container .select2-choice, .select2-container .select2-choices{
        color: #999;
    }
    </style>
</head>

<body class="fixed-navbar fixed-sidebar">
<div class="small-header">
    <div class="hpanel">
        <div class="panel-body">
            <div id="hbreadcrumb" class="pull-right">
                <ol class="hbreadcrumb breadcrumb">
                    <li>CINDATA PLS</li>
                    <li class="active">
                        <span>批次管理</span>
                    </li>
                </ol>
            </div>

            <h2 class="font-light m-b-xs">
                批次管理
            </h2>
        </div>
    </div>
</div>

<div class="content animate-panel">
    <div class="row">
        <g:form method="POST" controller="estateImportBatch" action="evaluateAccountBatchIndex" class="form-horizontal" role="form">
            <div class="hpanel hblue">
                <div class="panel-heading">
                    <div class="panel-tools">
                        <button class="btn btn-primary btn-xs" type="submit"><i class="fa fa-search"></i>查询</button>
                        <button class="btn btn-warning2 btn-xs" type="button" id="resetBtn">
                            <i class="fa fa-times"></i>重置</button>
                    </div>
                    查询
                </div>
                <div class="panel-body seach-group">
                    <div class="row flex">
                        <div class="form-group col-md-4">
                            <label  class="col-sm-3 control-label">批次名</label>
                            <div class="col-sm-9">
                                <input type="text" class="form-control" value="${params?.batchName}" id="batchName" name="batchName"  placeholder="请输入批次名"/>
                            </div>
                        </div>
                        <div class="form-group col-md-4">
                            <label class="col-md-3 control-label">处理状态</label>
                            <div class="col-sm-9">
                                <g:select class="form-control" name="status" id="status"
                                          from="${com.cindata.dictionary.ExecStatusDict.list()}"
                                          valueMessagePrefix="status" optionKey="name" optionValue="name"
                                          value="${params?.status}"
                                          noSelection="${["": '请选择处理状态']}"/>
                            </div>
                        </div>
                        <div class="form-group col-md-4">
                        </div>
                    </div>
                </div>
        </g:form>
    </div>

    </div>

    <div class="row">
        <div class="hpanel hgreen">
            <div class="panel-heading">
                <div class="panel-tools">
                    <a class="showhide"><i class="fa fa-chevron-up"></i></a>
                </div>
                全部批次
            </div>

            <div class="panel-body no-padding">
                <div class="table-responsive">
                    <table cellpadding="1" cellspacing="1" class="table table-striped table-bordered table-hover text-center">
                        <thead>
                        <tr>
                            <g:sortableColumn property="batchNumber" title="批次名" class="text-center" params="${params}"/>
                            <g:sortableColumn property="status" title="状态" class="text-center" params="${params}"/>
                            <g:sortableColumn property="evaluateType" title="处理方式" class="text-center" params="${params}"/>
                            <g:sortableColumn property="latestEvaluateAccount.name" title="评估机构" class="text-center" params="${params}"/>
                            <g:sortableColumn property="modifiedDate" title="评估时间" class="text-center" params="${params}"/>
                            <g:sortableColumn property="operator" title="操作" class="text-center" params="${params}"/>
                        </tr>
                        </thead>
                        <tbody>
                        <g:each in="${estateImportBatchList}">
                            <tr align="center">
                                <td>${it?.batchNumber}</td>
                                <td>${it?.status?.name}</td>
                                <td>${it?.evaluateType?.name}</td>
                                <td>${it?.latestEvaluateAccount?.name}</td>
                                <td><g:formatDate date="${it?.modifiedDate}" format="yyyy-MM-dd "></g:formatDate></td>
                                <td>
                                    <g:link class="btn btn-info btn-outline btn-xs" action="evaluateAccountBatchExport" id="${it?.id}">下载</g:link>
                                    <button class="btn btn-success btn-outline btn-xs btnModal" type="button" data-toggle="modal" dataNumber="${it.batchNumber}" data-target="#myModal7">上传</button>
                                </td>
                            </tr>
                        </g:each>
                        </tbody>
                    </table>
                </div>
            </div>

            <div class="panel-footer">
                <div class="pagination">
                    <g:paginate total="${estateImportBatchCount ?: 0}" params="${params}"/>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="modal fade hmodal-success" id="myModal7" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static">
    <div class="modal-dialog">
        <g:form controller="estateImportBatch" action="evaluateAccountBatchImport" method="post" enctype="multipart/form-data" id="uploadForm" class="formDataLine" target="hiddenFrame">
            <div class="modal-content">
                <div class="modal-body modalHeight">
                    <div class="form-horizontal">
                        <div class="form-group">
                            <label for="batch" class="col-md-2 control-label is-required" >批次名</label>
                            <div class="col-md-9">
                                <g:textField class="form-control m-b batchNumber" name="batchNumber" disabled="true"></g:textField>
                                <g:textField class="form-control m-b hide batchNumberValue" name="batchNumberValue"></g:textField>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-2">
                                <a href='javascript:void(0);' class="blueButton" style="line-height: 34px;font-size: 12px;">选择文件</a>
                                <input type="file" class="myFileUpload" id="myFile" name="myFile" accept=".csv"/>
                            </div>
                            <div class="col-md-10" style="padding-left:25px;">
                                <div id="file_div" class="file_show" ></div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="modal-footer">
                    <button type="button" class="btn btn-success start" id="import" name="import">
                        <span>开始上传</span>
                    </button>
                    <button type="reset" class="btn btn-danger" data-dismiss="modal">
                        <span>取消上传</span>
                    </button>
                </div>
            </div>
        </g:form>
    </div>
</div>

<div class="modal fade hmodal-warning in" id="myModal9" tabindex="-1" role="dialog" aria-hidden="true"
     data-backdrop="static" style="display: none; padding-right: 17px;">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="color-line"></div>

            <div class="modal-body">
                <div class="m progressLine">
                    <div class=" m-t-xs full progress-striped active progressLineC">
                        <div class="progressLineWidth">上传进度</div>

                        <div aria-valuemax="100" aria-valuemin="0" aria-valuenow="90" role="progressbar"
                             class=" progress-bar progress-bar-success" id="progressLine">
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<iframe src="" name="hiddenFrame" style="display:none"></iframe>
<g:javascript>
        
    
    $(".btnModal").click(function () {
        var batchNumberValue = $(this).attr("dataNumber").trim();
        $(".batchNumber").val(batchNumberValue);
        $(".batchNumberValue").val(batchNumberValue);
    });

    $(function () {

        //导入功能按钮执行
        $("#import").click(function () 
        {
            var myFile = $("#myFile").val();
            var ext_name = myFile.substr(myFile.lastIndexOf(".")+1);
            var file_ext_arr = [
                'csv'
            ];
            if (myFile == "") {
                $("#file_div").html("请选择文件");
                $("#file_div").css("color", "red");
                return;
            }
            if (file_ext_arr.indexOf(ext_name)==-1) {
                $("#file_div").html("文件格式不正确");
                $("#file_div").css("color", "red");
                return;
            }

            if (myFile !== "" && file_ext_arr.indexOf(ext_name)>-1) 
            {
                $(this).attr("type", "submit");
            }
        });

        $(".myFileUpload").change(function () {
            var arrs = $(this).val().split('\\');
            var filename = arrs[arrs.length - 1];
            $("#file_div").html(filename);
            $("#file_div").css("color", "#3498db");
        });
    })

    //重置按钮
    $("#resetBtn").click(function () {
        $("#batchName").val("");
        $("#s2id_status span:first").html("请选择处理状态");
        $("#status").val("");
    });

    function importCallback(_param) {
        swal({
            title: "导入成功",
            type: "success"
        }, function () {
            window.location = window.location;
        });

    }

</g:javascript>
<asset:javascript src="homer/vendor/jquery-validation/jquery.validate.min.js"/>
</body>
</html>
